home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / sys / types.h < prev    next >
C/C++ Source or Header  |  1999-10-30  |  6KB  |  172 lines

  1. /*  $NetBSD: types.h,v 1.23 1995/05/28 03:06:34 jtc Exp $   */
  2.  
  3. /*-
  4.  * Copyright (c) 1982, 1986, 1991, 1993
  5.  *  The Regents of the University of California.  All rights reserved.
  6.  * (c) UNIX System Laboratories, Inc.
  7.  * All or some portions of this file are derived from material licensed
  8.  * to the University of California by American Telephone and Telegraph
  9.  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  10.  * the permission of UNIX System Laboratories, Inc.
  11.  *
  12.  * Redistribution and use in source and binary forms, with or without
  13.  * modification, are permitted provided that the following conditions
  14.  * are met:
  15.  * 1. Redistributions of source code must retain the above copyright
  16.  *    notice, this list of conditions and the following disclaimer.
  17.  * 2. Redistributions in binary form must reproduce the above copyright
  18.  *    notice, this list of conditions and the following disclaimer in the
  19.  *    documentation and/or other materials provided with the distribution.
  20.  * 3. All advertising materials mentioning features or use of this software
  21.  *    must display the following acknowledgement:
  22.  *  This product includes software developed by the University of
  23.  *  California, Berkeley and its contributors.
  24.  * 4. Neither the name of the University nor the names of its contributors
  25.  *    may be used to endorse or promote products derived from this software
  26.  *    without specific prior written permission.
  27.  *
  28.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  29.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  32.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38.  * SUCH DAMAGE.
  39.  *
  40.  *  @(#)types.h 8.4 (Berkeley) 1/21/94
  41.  */
  42.  
  43. #ifndef _SYS_TYPES_H_
  44. #define _SYS_TYPES_H_
  45.  
  46. /* Machine type dependent parameters. */
  47. #include <machine/types.h>
  48.  
  49. #include <machine/ansi.h>
  50. #include <machine/endian.h>
  51.  
  52. #ifndef _POSIX_SOURCE
  53. typedef unsigned char   u_char;
  54. typedef unsigned short  u_short;
  55. typedef unsigned int    u_int;
  56. typedef unsigned long   u_long;
  57. typedef unsigned short  ushort;     /* Sys V compatibility */
  58. typedef unsigned int    uint;       /* Sys V compatibility */
  59. #endif
  60.  
  61. typedef u_int64_t   u_quad_t;   /* quads */
  62. typedef int64_t     quad_t;
  63. typedef quad_t *    qaddr_t;
  64.  
  65. typedef char *      caddr_t;    /* core address */
  66. typedef int32_t     daddr_t;    /* disk address */
  67. typedef int16_t     dev_t;      /* device number */
  68. typedef u_int32_t   fixpt_t;    /* fixed point number */
  69. typedef u_int16_t   gid_t;      /* group id */
  70. typedef u_int32_t   ino_t;      /* inode number */
  71. typedef long        key_t;      /* IPC key (for Sys V IPC) */
  72. typedef u_int16_t   mode_t;     /* permissions */
  73. typedef u_int16_t   nlink_t;    /* link count */
  74. typedef int32_t     off_t;      /* file offset */
  75. typedef int32_t     pid_t;      /* process id */
  76. typedef int32_t     rlim_t;     /* resource limit */
  77. typedef int32_t     segsz_t;    /* segment size */
  78. typedef int32_t     swblk_t;    /* swap offset */
  79. typedef u_int16_t   uid_t;      /* user id */
  80.  
  81. /*
  82.  * These belong in unistd.h, but are placed here too to ensure that
  83.  * long arguments will be promoted to off_t if the program fails to 
  84.  * include that header or explicitly cast them to off_t.
  85.  */
  86. #ifndef _POSIX_SOURCE
  87. #ifndef _KERNEL
  88. #include <sys/cdefs.h>
  89. __BEGIN_DECLS
  90. off_t    lseek __P((int, off_t, int));
  91. int  ftruncate __P((int, off_t));
  92. int  truncate __P((const char *, off_t));
  93. __END_DECLS
  94. #endif /* !_KERNEL */
  95. #endif /* !_POSIX_SOURCE */
  96.  
  97. #ifndef _POSIX_SOURCE
  98. /* Major, minor numbers, dev_t's. */
  99. #define major(x)    ((int32_t)(((u_int32_t)(x) >> 8) & 0xff))
  100. #define minor(x)    ((int32_t)((x) & 0xff))
  101. #define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))
  102. #endif
  103.  
  104. #ifdef  _BSD_CLOCK_T_
  105. typedef _BSD_CLOCK_T_   clock_t;
  106. #undef  _BSD_CLOCK_T_
  107. #endif
  108.  
  109. #ifdef  _BSD_SIZE_T_
  110. typedef _BSD_SIZE_T_    size_t;
  111. #undef  _BSD_SIZE_T_
  112. #endif
  113.  
  114. #ifdef  _BSD_SSIZE_T_
  115. typedef _BSD_SSIZE_T_   ssize_t;
  116. #undef  _BSD_SSIZE_T_
  117. #endif
  118.  
  119. #ifdef  _BSD_TIME_T_
  120. typedef _BSD_TIME_T_    time_t;
  121. #undef  _BSD_TIME_T_
  122. #endif
  123.  
  124. #ifndef _POSIX_SOURCE
  125. #define NBBY    8       /* number of bits in a byte */
  126.  
  127. /*
  128.  * Select uses bit masks of file descriptors in longs.  These macros
  129.  * manipulate such bit fields (the filesystem macros use chars).
  130.  * FD_SETSIZE may be defined by the user, but the default here should
  131.  * be enough for most uses.
  132.  */
  133. #ifndef FD_SETSIZE
  134. #define FD_SETSIZE  256
  135. #endif
  136.  
  137. typedef int32_t fd_mask;
  138. #define NFDBITS (sizeof(fd_mask) * NBBY)    /* bits per mask */
  139.  
  140. #ifndef howmany
  141. #define howmany(x, y)   (((x) + ((y) - 1)) / (y))
  142. #endif
  143.  
  144. typedef struct fd_set {
  145.     fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  146. } fd_set;
  147.  
  148. #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  149. #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  150. #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  151. #define FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
  152. #define FD_ZERO(p)  bzero(p, sizeof(*(p)))
  153.  
  154. #if defined(__STDC__) && defined(_KERNEL)
  155. /*
  156.  * Forward structure declarations for function prototypes.  We include the
  157.  * common structures that cross subsystem boundaries here; others are mostly
  158.  * used in the same place that the structure is defined.
  159.  */
  160. struct  proc;
  161. struct  pgrp;
  162. struct  ucred;
  163. struct  rusage;
  164. struct  file;
  165. struct  buf;
  166. struct  tty;
  167. struct  uio;
  168. #endif
  169.  
  170. #endif /* !_POSIX_SOURCE */
  171. #endif /* !_SYS_TYPES_H_ */
  172.